<template>
  <div class="flight-detail-wrapper">
    <div class="personnel-distribution-title">
      <div class="personnel-distribution-name">
        航班入境人员分流隔离情况
      </div>
    </div>
    <div class="personnel-distribution-swiper">
        <div class="swiper-wrapper card-list">
          <div
            class="swiper-slide left-side-slider"
            v-for="(item, index) in cardList"
            :key="index"
          >
            <bi-flight-card
              :data="item"
            >
              <template slot="hotel" slot-scope="{item, index}">
                <hotel-item
                  :type="handleRenderItemType(item, index)"
                  :url="`/roomKanban?hotelId=${item.hotelId}&hotelName=${item.hotelName}`"
                  :name="item.hotelName"
                  :people-total="item.hotelNum"
                ></hotel-item>
              </template>
            </bi-flight-card>
          </div>
        </div>
    </div>
  </div>
</template>

<script>
import mySwiper from "@/components/my-swiper";
import { flightIsolateByDate } from "../index";
import HotelItem from './hotelItem'
import BiFlightCard from 'board/common/flight-card'

export default {
  props: {
    flightTime: {
      type: String,
      default: () => "",
    },
  },
  data() {
    return {
      cardList: [],
      targetIndex: 1, //可给swiper传入默认值
      swiperOption: {
        direction: "horizontal", // 垂直切换选项
        button: true, //是否显示左右两边的按钮
        slidesPerView: 4, //一页显示slider数量
        spaceBetween: 0, // slider间距
        autoplay: true, //是否自动轮播
        autoplayDelay: 5000, //自动轮播间隔时间
        disableOnInteraction: true, //用户操作后是否停止轮播
        // loopAdditionalSlides: 0,
        slidesPerGroup: 4, // 分组，一组显示slider数量
      },
      targetIndexMini: 1, //可给swiper传入默认值
      swiperOptionMini: {
        direction: "horizontal", // 垂直切换选项
        button: true, //是否显示左右两边的按钮
        slidesPerView: 3, //一页显示slider数量
        spaceBetween: "7px", // slider间距
        autoplay: false, //是否自动轮播
        // autoplayDelay: 5000, //自动轮播间隔时间
        // disableOnInteraction: true, //用户操作后是否停止轮播
        // loopAdditionalSlides: 0,
        slidesPerGroup: 3, // 分组，一组显示slider数量
      },
    };
  },
  watch: {
    flightTime: {
      handler(val) {
        this.getFlightData(val);
      },
      immediate: true,
    },
  },
  methods: {
    handleRenderItemType (item, index) {
      const ni = index + 1
          if (!(ni % 3)) {
              return 'triple'
          } else if (!(ni % 2)) {
              return 'double'
          } else if (!(ni % 1)) {
              return 'once'
          }
    },
    //获取swiper实例
    getSwiperInstance(swiper) {
      this.swiper = swiper;
    },
    getSwiperInstanceMini(swiper) {
      this.swiper = swiper;
    },
    // 获取当天航班数据
    async getFlightData(time) {
      if (time) {
        const { data } = await flightIsolateByDate(time);
        this.cardList = data.data
      }
    }
  },
  components: {
    mySwiper,
    HotelItem,
    BiFlightCard
  },
};
</script>

<style lang="scss" scoped>
.flight-detail-wrapper {
  // padding: 0 16px;
  background: url('../../../assets/images/flightDetail_bg.png') no-repeat top;
  background-size: 343px 461px;
  padding-bottom: 12px;
  .personnel-distribution-title {
    // display: flex;
    text-align: center;
  }
  .personnel-distribution-icon {
    width: 32px;
    height: 32px;
    margin-right: 14px;
    background: url("../../../assets/icon/flight-icon/flight-title.png")
      no-repeat;
    background-size: contain;
  }
  .personnel-distribution-name {
    font-size: 18px;
    font-weight: bold;
    // color: #555555;
    padding-top: 32px;
    color: #fff;
    line-height: 18px;
  }
  .personnel-distribution-swiper {
    padding: 20px 13px 0;
  }
  .swiper-slide{
    &:not(:last-child) {
      margin-bottom: 12px;
    }
  }
  .card-list {
    display: block;
  }
  .card-item {
    padding-top: 1px;
    width: 316px;
    height: 392px;
    background: url("../../../assets/images/flightDetail_bg2.png") no-repeat;
    background-size: 100% 100%;
    margin-top: 16px;
    &:first-child {
      margin-top: 0;
    }
  }
  .card-header {
    display: flex;
    margin: 17px 17px 0;
    height: 35px;
    border-bottom: 1px solid #ececec;
  }
  .header-icon {
    width: 22px;
    height: 22px;
    background: url("../../../assets/icon/flight-icon/flight-number.png")
      no-repeat;
    background-size: contain;
  }
  .header-title {
    font-size: 20px;
    font-weight: bold;
    color: #60b2fd;
    line-height: 21px;
  }
  .title-margin {
    margin: 0 8px 0 10px;
  }
  .card-content {
    margin: 0 17px 0;
  }
  .content-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  .card-name {
    display: flex;
    font-size: 12px;
    // font-family: SourceHanSansCN-Normal, SourceHanSansCN;
    font-family: SourceHanSansCN-Normal;
    font-weight: 400;
    color: #555555;
    line-height: 12px;
    // padding: 0 11px 0 6px;
    padding-left: 6px;
  }
  .country-icon {
    width: 11px;
    height: 14px;
    margin-right: 11px;
    background: url("../../../assets/icon/flight-icon/icon_position.png")
      no-repeat;
    background-size: contain;
  }
  .passengers-icon {
    width: 10px;
    height: 12px;
    margin-right: 11px;
    background: url("../../../assets/icon/flight-icon/icon_passengers.png")
      no-repeat;
    background-size: contain;
  }
  .landing-icon {
    width: 13px;
    height: 13px;
    margin-right: 11px;
    background: url("../../../assets/icon/flight-icon/icon_time.png")
      no-repeat;
    background-size: contain;
  }
  .distribution-icon {
    width: 14px;
    height: 17px;
    margin-right: 10px;
    background: url("../../../assets/icon/flight-icon/distribution-place.png")
      no-repeat;
    background-size: contain;
  }
  .card-label {
    font-size: 18px;
    font-family: SourceHanSansCN-Bold, SourceHanSansCN;
    font-weight: bold;
    color: #4D9CFD;
    line-height: 18px;
    > span {
      display: inline-block;
      font-size: 10px;
      transform: scale(0.83);
    }
  }
  .card-label-time {
    font-size: 12px;
    font-family: PingFang SC;
    font-weight: 600;
    color: #373737;
    // letter-spacing: 9px;
  }
  .content-item-bottom {
    padding-bottom: 33px;
    &:nth-child(2) {
      padding-bottom: 20px;
    }
    .startState, .arrivalCity{
      font-family: Source Han Sans CN;
      position: relative;
      &_name {
        font-size: 20px;
        color: #222222;
        line-height: 20px;
        font-weight: bold;
        padding: 18px 0 14px 11px;
      }
      &_title {
        font-size: 12px;
        color: rgba(133, 133, 133, .8);
        // margin-left: 11px;
      }
    }
    .startState {
      &_title {
        width: 50px;
        position: absolute;
        left: 11px;
      }
    }
    .arrivalCity {
      // width: 100px;
      &_name {
        color: #8F8F8F;
        padding: 18px 11px 14px 0;
      }
      &_title {
        width: 50px;
        position: absolute;
        right: 4px;
      }
    }
  }
  .content-item-border {
    // height: 40px;
    padding-bottom: 26px;
    border-bottom: 1px dashed #60b2fd;
  }
  .content-item-tb {
    padding: 20px 0 16px 0;
    .positionTitlt {
      // line-height: 14px;
      padding-top: 2px;
    }
  }
  .card-footer {
    /*display: flex;*/
    // justify-content: space-between;
    padding: 0 17px 17px;
  }
  .hotel-name-card {
    width: 80px;
    height: 75px;
    border-radius: 2px;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    margin-right: 7px;
    &:nth-child(n) {
      background: rgba(97, 195, 157, 0.1);
      color: #61c39d;
      border: 1px solid #61c39d;
      .name-card-horn {
        background: url("../../../assets/icon/flight-icon/horn-green.png")
          no-repeat;
        background-size: 10px 8px;
      }
    }
    &:nth-child(2n) {
      background: rgba(77, 156, 253, 0.1);
      color: #4d9cfd;
      border: 1px solid #4d9cfd;
      .name-card-horn {
        background: url("../../../assets/icon/flight-icon/horn-blue.png")
          no-repeat;
        background-size: 10px 8px;
      }
    }
    &:nth-child(3n) {
      background: rgba(118, 98, 213, 0.1);
      color: #7662d5;
      border: 1px solid #7662d5;
      .name-card-horn {
        background: url("../../../assets/icon/flight-icon/horn-violet.png")
          no-repeat;
        background-size: 10px 8px;
      }
      margin-right: 0px;
    }
  }
  .name-card-horn {
    width: 12px;
    height: 12px;
    margin: 1px 0 0 67px;
    width: 100%;
  }
  .name-card-num {
    // padding: 13px 0 5px 0;
    padding-top: 12px;
    font-size: 18px;
    font-family: DINAlternate-Bold;
    line-height: 21px;
  }
  .hotel-name-label {
    font-size: 12px;
    font-family: PingFangSC-Semibold;
    line-height: 17px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }
  /deep/ .swiper-button-prev {
    left: -5px;
  }
  /deep/ .swiper-button-next {
    right: -12px;
  }
  .flight-detail__empty{
    text-align: center;
    padding-top: 36px;
    font-size: 14px;
    color: #bababa;
  }
}
</style>
<style lang="scss">
.flight-detail-wrapper {
  .card-footer {
    .swiper-button-wrapper .my-swiper-wrapper.hasButton {
      width: calc(100% - 28px);
    }
  }

}
</style>
